/**
 * @file wa_pid.c
 *
 */

 /*********************
  *      INCLUDES
  *********************/
#include "wa_pid.h"
#include "wa_wm.h"
#include "wa_tick.h"
#include "wa_win.h"
/*********************
*      DEFINES
*********************/

/**********************
*      TYPEDEFS
**********************/

/**********************
*  STATIC PROTOTYPES
**********************/

/**********************
*  STATIC VARIABLES
**********************/
static int wa_input_sign_id;
static wa_result wa_input_sign_have;
static wa_result wa_input_state_enable;
/**********************
*      MACROS
**********************/

/**********************
*   GLOBAL FUNCTIONS
**********************/

/**
 * input module init
 */
void wa_input_module_init(void)
{
	wa_input_sign_id = WA_SIGNAL_SYSTEM_MAX;
	wa_input_sign_have = wa_nok;
	wa_input_state_enable = wa_nok;
}

/**
 * input set enable
 * @param input_enable
 */
void wa_input_enable(wa_result input_enable)
{
	wa_input_state_enable = input_enable;
}

/**
 * input is enable or not
 */
wa_result wa_input_is_enable(void)
{
	return wa_input_state_enable;
}

/**
 * input send sign
 * @param pid_state
 */
void wa_input_send_sign(int sign_id)
{
	if (wa_input_state_enable == wa_ok)
	{
		wa_input_sign_id = sign_id;
		wa_input_sign_have = wa_ok;
	}
}

/**
 * input handle
 */
void wa_input_handle(void)
{
#if USE_WA_WIN != 0
	if (wa_input_state_enable == wa_ok)
	{
		if (wa_input_sign_have == wa_ok)
		{
			wa_obj* top_win;
			wa_win_ext* ext;
			top_win = (wa_obj*)wa_ll_get_head(&top_scr_obj.child_ll);
			ext = wa_obj_get_ext_attr(top_win);
			wa_wm_send_sign_nodata(ext->panel, wa_input_sign_id);
			wa_input_sign_have = wa_nok;
		}
	}
#endif
}

/**********************
 *   STATIC FUNCTIONS
 **********************/
